import Vue from "vue";
import App from "./App.vue";
import router from "@/router";
import store from "@/store";
import Pagination from "@/components/Pagination";
import TypeNav from "@/components/TypeNav";
import Carousel from "@/components/Carousel";
import VueLazyload from "vue-lazyload";
import { CarouselItem, MessageBox } from "element-ui";
import VeeValidate from "vee-validate";
Vue.config.productionTip = false;
//注册导航栏为全局组件
Vue.component(TypeNav.name, TypeNav);
Vue.component(Carousel.name, Carousel);
Vue.component(Pagination.name, Pagination);
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
import "@/mock/mockServe.js";
import "swiper/css/swiper.css";
//统一引入aip接口
import * as API from "@/api";
import loadingGif from "@/assets/loading.gif";
import zh_CN from "vee-validate/dist/locale/zh_CN";
Vue.use(VueLazyload, {
  loading: loadingGif,
});
Vue.use(VeeValidate);
VeeValidate.Validator.localize("zh_CN", {
  messages: {
    ...zh_CN.messages,
    is: (field) => `${field}必须与密码相同`, // 修改内置规则的 message，让确认密码和密码相同
  },
  attributes: {
    phone: "手机号",
    code: "验证码",
    password: "密码",
    passwordComfirm: "确认密码",
    isCheck: "同意用户协议",
  },
});
VeeValidate.Validator.extend("isCheck", {
  validate: (value) => {
    return value;
  },
  getMessage: (field) => field + "请先勾选同意协议",
});

new Vue({
  render: (h) => h(App),
  beforeCreate() {
    Vue.prototype.$bus = this;
    Vue.prototype.$API = API;
  },
  //在全局VUE上注册路由信息：当这里注册路由时，组件身上将都会有$route和$router属性
  //$route：一般获取路由信息：路径、query、params等
  //$router：一般进行编程式导航进行路由跳转，push/replace
  router,
  store,
}).$mount("#app");
